package com.houger.ddd.seckill.infra.datamanager;

import com.houger.ddd.datamanager.manager.aop.DataCache;
import com.houger.ddd.datamanager.manager.aop.DataCacheEvict;
import com.houger.ddd.datamanager.utils.CacheType;
import com.houger.ddd.seckill.infra.entity.ActivityTemplateUiConfig;
import com.houger.ddd.seckill.repository.ActivityTemplateUiConfigRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;


@Service
public class ActivityTemplateUiConfigDataManager {

    @Resource
    ActivityTemplateUiConfigRepository activityTemplateUiConfigRepository;

    /**
     * 根据活动模板ID查询UI配置信息
     */
    @DataCache(group = "activity-ui",key = "('templateId=').concat(#templateId)",type = {CacheType.LOCAL, CacheType.REDIS},localExpire = 1 * 60, redisExpire = 1 * 60)
    public ActivityTemplateUiConfig queryUiByTemplateId(Long templateId) {
        return this.activityTemplateUiConfigRepository.findByTemplateId(templateId).orElseThrow();
    }

    @DataCacheEvict(group = "activity-ui",key = {
            "('templateId=').concat(#templateId)"},
            type = {CacheType.LOCAL, CacheType.REDIS})
    public void evict(Long templateId){

    }

}
